﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;
using ExtBusiness.Admin;
using ExtBusiness.FlowOperation;
using System.Data;
using WF_Business;

public partial class Xnjc_staff_form : PageBase
{
    public string wname = string.Empty;
    public string stepName = string.Empty;
    public string timeFromOfAccept = string.Empty;
    public string timeToOfAccept = string.Empty;
    public string intervalType = string.Empty;
    public string userID = string.Empty;
    public string userid = string.Empty;
    public ClsWorkFlow clsWorkFlow = new ClsWorkFlow();
    public DataTable dtWorkFlowNames;
    public ArrayList alWorkStatus = null;
    public List<ExtBusiness.Struct.UserStruct> listUserStruct = null;
    protected string strhtml1 = string.Empty;
    protected string strhtml2 = string.Empty;

    protected void Page_Load(object sender, EventArgs e)
    {
         wname = Request["wname"];
        if (String.IsNullOrEmpty(wname))
            wname = Request["hidwname"];//从隐藏的文本框取
         stepName = Request["stepName"];
         timeFromOfAccept = Request["timeFromOfAccept"];
         timeToOfAccept = Request["timeToOfAccept"];
         intervalType = Request["intervalType"];
         userID = Request["userID"];
         userid = UserId;

        //判断当前登录用户是否为系统管理员
         bool ISsystemUser = SystemManager.IsSystemUser(userid);

        if (!ISsystemUser)
        {
            string strSql = "select t.task  from xt_query_right t  where t.userid = '" + userid + "'";
            SysParams.OAConnection().RunSql(strSql, out dtWorkFlowNames);
        }
        else
        {
            dtWorkFlowNames = clsWorkFlow.GetFlowName();
        }
    
        if (!string.IsNullOrEmpty(wname) && !string.IsNullOrEmpty(stepName))
        {
            String gid = ExtBusiness.Admin.Department.GetGroupIdOfStep(wname, stepName);
            listUserStruct = ExtBusiness.Admin.User.GetUserInfoByGroupId(gid);

            if (!string.IsNullOrEmpty(userID))
            {
                alWorkStatus = clsWorkFlow.WorkStatusOfPersonalStep(wname, stepName, userID, timeFromOfAccept,
                    timeToOfAccept, intervalType);
            }
        }

        foreach (System.Data.DataRow drName in dtWorkFlowNames.Rows)
        {
            string selected = "";
            if (!String.IsNullOrEmpty(wname) && wname == drName[0].ToString())
                selected = "selected";
            strhtml1+= string.Format("<option value='{0}' " + selected + ">{0}</option>", drName[0]);
            
        }

        if (listUserStruct != null)
        {
            foreach (ExtBusiness.Struct.UserStruct userInfo in listUserStruct)
            {
                strhtml2= string.Format("<option value='{0}'>{1}</option>",
                    userInfo.UserId, userInfo.UserRealName);
              
            }
        }
    }
}
